package com.code.common.vo;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

import java.io.Serializable;


@ApiModel(description="统一返回结果")
public class ResultData implements Serializable {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value="结果码")
    private int code;
    @ApiModelProperty(value="返回信息")
    private String msg;

    @ApiModelProperty(value="返回数据")
    private Object data;

    public ResultData() {}


    public ResultData(int code, String msg, Object data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public ResultData succ(int code, String msg) {
        return new ResultData(code,msg,null);
    }

    public ResultData succ(int code, String msg, Object data) {
        return new ResultData(code,msg,data);
    }

    public ResultData fail(int code, String msg) {
        return new ResultData(code,msg,null);
    }

    public ResultData fail(int code, String msg, Object data) {
        return new ResultData(code,msg,data);
    }


    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    @Override
    public String toString() {
        return "ResultData{" +
                "code=" + code +
                ", msg='" + msg + '\'' +
                ", data=" + data +
                '}';
    }






}
